package com.web;

import com.pojo.TongZhi;
import com.service.TongZhiService;
import com.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(origins = "http://localhost:8081")
@RestController
public class TongZhiController {
    @Autowired
    private TongZhiService tongZhiService;

    @RequestMapping("/tongzhi")
    public ResultEntity tongzhi() {
        return ResultEntity.ok(tongZhiService.findAll());
    }
    @RequestMapping("/mohu")
    public ResultEntity mohu(TongZhi tongZhi) {
        System.out.println("-----------------------------------");
        System.out.println(tongZhi);
        return ResultEntity.ok(tongZhiService.findmh(tongZhi));
    }

    @RequestMapping("/bianji")
    public ResultEntity update(TongZhi tongZhi) {
        return ResultEntity.ok(tongZhiService.update(tongZhi));
    }

    @RequestMapping("/insert")
    public ResultEntity tianjia(TongZhi tongZhi) {
        return ResultEntity.ok(tongZhiService.tianjia(tongZhi));
    }

    @RequestMapping("/shanchu")
    public ResultEntity shanchu(TongZhi tongZhi) {
        return ResultEntity.ok(tongZhiService.delete(tongZhi));
    }
}
